package view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import darksideoftheloom.Attendee;
import darksideoftheloom.Event;

/**
 * This class shows an organizer a list of all Attendees, Contestants, and
 * Judges.
 * 
 * @author Shane Kwon
 * @version 2013-03-09
 * 
 */
@SuppressWarnings("serial")
public class BeweaveOrganizerPanel extends JPanel {
    /**
     * The width of the panel.
     */
    private static final int WIDTH = 1024;

    /**
     * The number of columns in the display table.
     */
    private static final int COLS = 5;

    /**
     * The height of the panel.
     */
    private static final int HEIGHT = 768;

    /**
     * 
     * @param the_weavent
     *            The weaving Event
     * @param the_panel
     *            the panel container, used for switching between panels
     */
    public BeweaveOrganizerPanel(final Event the_event, final JPanel the_panel) {
        super();
        setLayout(new BorderLayout());
        String[] column_names = { "Name", "Phone Number", "Address", "Email",
                "Username" };
        List<Attendee> everyone = the_event.getAttendees();
        Object[][] row_data = new Object[everyone.size()][COLS];
        for (int i = 0; i < everyone.size(); i++) {
            Attendee a = everyone.get(i);
            row_data[i][0] = a.getName();
            row_data[i][1] = a.getPhoneNumber();
            row_data[i][2] = a.getAddress();
            row_data[i][3] = a.getEmail();
            row_data[i][4] = a.getUsername();
        }
        JTable table = new JTable(row_data, column_names);
        JScrollPane scrollPane = new JScrollPane(table);
        table.setFillsViewportHeight(true);
        add(scrollPane, BorderLayout.CENTER);
        setPreferredSize(new Dimension(WIDTH, HEIGHT));
    }
}
